$(function () {
  var xhr = new XMLHttpRequest()
  xhr.open('GET', 'http://www.liulongbin.top:3005/api/getnewslist')
  xhr.send()
  xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
      template.defaults.imports.timer = function (arr) {
        var data = new Date(arr)
        const Y = data.getFullYear()
        const M = (data.getMonth() + 1).toString().padStart('2', 0)
        const D = data.getUTCDate().toString().padStart('2,0')
        const H = data.getHours().toString().padStart('2,0')
        const mm = data.getMinutes().toString().padStart('2,0')
        const ss = data.getSeconds().toString().padStart('2,0')
        return Y + '-' + M + '-' + D + ' ' + H + ':' + mm + ':' + ss
      }
      console.log(JSON.parse(xhr.responseText));
      var data = JSON.parse(xhr.responseText).message

      let arr = template('tpl-user', {
        data
      })
      $(".publish").html(arr)

    }
  }
})